package freespiritsocial.io.user.viewmodel

import freespiritsocial.io.user.data.model.bean.PostPojo
import freespiritsocial.io.user.network.apiService
import freespiritsocial.io.user.network.upload.IUploadApi
import freespiritsocial.io.user.network.upload.UploadDelegate
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.callback.databind.StringObservableField
import me.hgj.jetpackmvvm.ext.request

class ChatViewModel: BaseViewModel(),IUploadApi by UploadDelegate() {
    val sendText = StringObservableField()
    val topic = StringObservableField()
    val message = StringObservableField()
    var userId = ""
    fun chatReportTopic(callback: (List<String>) -> Unit) {
        request({
            apiService.chatReportTopic()
        },{
            callback(it)
        })
    }

    fun chatReport(callback: () -> Unit) {
        request({
            apiService.chatReport(
                hashMapOf("issue" to topic.get(),"message" to message.get(),"reportUserId" to userId)
            )
        },{
            topic.set("")
            message.set("")
            callback()
        },isShowDialog = true)
    }

    fun getPost(id: Long?,callback: (PostPojo) -> Unit) {
        request({
            apiService.getInvitationDetail(id)
        },{
            callback(it)
        },isShowDialog = true)
    }
}